package com.hualan.sfzy.utils;

public class TimeConverter {

    public static String toMinSecStr(long totalSeconds) {
        if (totalSeconds < 0) {
            throw new IllegalArgumentException("总时长需要大于0");
        }
        long hours   =  totalSeconds / 3600;
        long minutes = (totalSeconds % 3600) / 60;
        long seconds =  totalSeconds % 60;
        StringBuilder sb = new StringBuilder();
        if (hours > 0) {
            sb.append(hours).append("小时");
        }
        if (minutes > 0) {
            sb.append(minutes).append("分");
        }
        if (seconds > 0 || sb.length() == 0) {
            sb.append(seconds).append("秒");
        }
        return sb.toString();
    }
}